<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<style>
    .form-group {
        margin-top: 10px;
    }

    .staffApply {
        float: left;
        margin-left: 20px;
    }
</style>
<script type="text/javascript">
    function saveOperationApply() {
        $.ajax({
            //添加
            url: "${ctx}/operation/operationScheduleAudit/save",
            type: "POST",
            dataType: "json",
            data: $('#inputForm').serialize(),
            success: function (data) {
                if (data.code == "success") {
                    toastr.success('保存成功');
                    $("#contentDiv").load('${ctx}/operation/operationScheduleAudit/index',function(){
                        hideShowTableTd('contentTable', '3,4,5,6,7', '2');
                    });
                    $("#operationRigthCenterDiv").load('${ctx}/operation/operationScheduleAudit/auditForm');
                }
                else {
                    toastr.success('保存失败');
                }
            }
        })
    }

    /*分配人员*/
    function assignButton(inputShow, inputHide) {
        var userIds = $("#" + inputHide).val();
        layerTree = layer.open({
            title: '分配人员',
            type: 2,
            area: ['500px', '520px'],
            fixed: false, //不固定
            maxmin: true,
            content: '${ctx}/sys/orgRole/usertorole?userId=' + userIds,
            btn: ['确定', '取消'],
            yes: function (index, layero) {
                var resultIds = $(layero).find("iframe")[0].contentWindow.resultIds;
                var resultNames = $(layero).find("iframe")[0].contentWindow.resultNames;
                if((inputShow=='zdDoctorName'||inputShow=='myDoctorName'||inputShow=='kdDoctorNames') && resultNames.indexOf(",") > 0){
                    layer.alert('请勿选择多个医生',{
                        icon: 2,
                        skin: 'layer-ext-moon'
                    })
                }else{
                    console.log(inputShow+"+++++"+inputHide)
                    $("#" + inputShow).val(resultNames);
                    $("#" + inputHide).val(resultIds);
                    layer.close(index);
                }
            }, no: function (index) {
                layer.close(index);
            }
        });
    }
</script>
<section class="main-content col-lg-12">
    <div class="content-wrap" id="operationRigthCenterDiv">
        <div class="panel-body">
            <form:form id="inputForm" data-parsley-validate="" modelAttribute="operationSchedule"
                       method="post" class="form-horizontal">
                <form:hidden path="inoroutFlag" />
                <form:hidden path="operStatus"/>
                <form:hidden path="clinicId"/>
                <form:hidden path="patientId"/>
                <form:hidden path="applyId"/>
                <form:hidden path="id"/>
                <form:hidden path="orgId"/>
                <fieldset>
                    <legend><img src="${ctxStatic}/images/left.png" class="pull-left mt8">手术人员信息<img
                            src="${ctxStatic}/images/right.png" class="pull-right mt8"></legend>
                    <div class="col-sm-12">
                        <div class="form-group col-sm-6">
                            <label class="col-sm-4 control-label">主刀医生：</label>

                            <div class="col-sm-8">
                                <form:hidden path="zdStaffBefore.userId" id="zdDoctor"></form:hidden>
                                <input type="hidden" name="zdStaffBefore.operationLocal" value="0"
                                       class="form-control"/>
                                <input  class="form-control" id="zdDoctorName" value="${operationSchedule.zdStaffBefore.userNames}"  type="text" onclick="assignButton('zdDoctorName','zdDoctor')" placeholder="分配人员"/>
                            </div>
                        </div>
                        <div class="form-group col-sm-6">
                            <label class="col-sm-4 control-label">麻醉医生：</label>

                            <div class="col-sm-8">
                                <form:hidden path="myStaffBefore.userId" id="myDoctor"></form:hidden>
                                <input name="myStaffBefore.operationLocal" value="1"  class="form-control" type="hidden"/>
                                <input  class="form-control" id="myDoctorName" value="${operationSchedule.myStaffBefore.userNames}"  type="text" onclick="assignButton('myDoctorName','myDoctor')" placeholder="分配人员"/>
                            </div>
                        </div>
                        <div class="form-group col-sm-6">
                            <label class="col-sm-4 control-label">输血医生：</label>

                            <div class="col-sm-8">
                                <form:hidden path="sxStaffBefore.userIds" id="sxDoctor"></form:hidden>
                                <input name="sxStaffBefore.operationLocal" value="2"  class="form-control" type="hidden"/>
                                <input  class="form-control" id="sxDoctorNames" value="${operationSchedule.sxStaffBefore.userNames}" type="text" onclick="assignButton('sxDoctorNames','sxDoctor')" placeholder="分配人员"/>
                            </div>
                        </div>

                        <div class="form-group col-sm-6">
                            <label class="col-sm-4 control-label">麻醉助手：</label>

                            <div class="col-sm-8">
                                <form:hidden path="mzStaffBefore.userIds" id="mzDoctor"></form:hidden>
                                <input name="mzStaffBefore.operationLocal" value="3"  class="form-control" type="hidden"/>
                                <input  class="form-control" id="mzDoctorNames" value="${operationSchedule.mzStaffBefore.userNames}" type="text" onclick="assignButton('mzDoctorNames','mzDoctor')" placeholder="分配人员"/>
                            </div>
                        </div>
                        <div class="form-group col-sm-12">
                            <label class="col-sm-2 control-label">医生助手：</label>
                            <div class="col-sm-8">
                                <form:hidden path="yzStaffBefore.userIds" id="yzDoctor"></form:hidden>
                                <input name="yzStaffBefore.operationLocal" value="4"  class="form-control" type="hidden"/>
                                <input  class="form-control" id="yzDoctorNames" value="${operationSchedule.yzStaffBefore.userNames}" type="text" onclick="assignButton('yzDoctorNames','yzDoctor')" placeholder="分配人员"/>
                            </div>
                        </div>
                        <div class="form-group col-sm-12">
                            <label class="col-sm-2 control-label">上台护士：</label>
                            <div class="col-sm-8">
                                <form:hidden path="stStaffBefore.userIds" id="stDoctor"></form:hidden>
                                <input name="stStaffBefore.operationLocal" value="5"  class="form-control" type="hidden"/>
                                <input  class="form-control" id="stDoctorNames" value="${operationSchedule.stStaffBefore.userNames}" type="text" onclick="assignButton('stDoctorNames','stDoctor')" placeholder="分配人员"/>
                            </div>
                        </div>
                        <div class="form-group col-sm-12">
                            <label class="col-sm-2 control-label">供应护士：</label>
                            <div class="col-sm-8">
                                <form:hidden path="gyStaffBefore.userIds" id="gyDoctor"></form:hidden>
                                <input name="gyStaffBefore.operationLocal" value="6"  class="form-control" type="hidden"/>
                                <input  class="form-control" id="gyDoctorNames" value="${operationSchedule.gyStaffBefore.userNames}" type="text" onclick="assignButton('gyDoctorNames','gyDoctor')" placeholder="分配人员"/>
                            </div>
                        </div>
                    </div>
                </fieldset>
        <div class="form-group">
            <div style="margin: 15px" class="pull-right">
                <input id="btnSubmit" class="btn btn-primary" type="button" value="确 认"
                       onclick="saveOperationApply()">&nbsp;
            </div>
        </div>

            </form:form>
    </div>
    </div>
</section>

